package testbean;

import com.dys.spring.bean.User;
import com.dys.spring3.controller.UserController;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author: 疾风
 * @ClassName: BeanAnnoTest
 * @Description: 通过接口注入
 * @CreateDate: 2024/10/18
 * @Version: v1.0.0
 */
public class BeanAnnoInterfaceTest2 {
    private ApplicationContext context;

    @Before
    public void init() {
        context = new ClassPathXmlApplicationContext("application.xml");
    }

    /**
     * 使用注解标识
     */
    @Test
    public void testBeanByAnnotation() {
        User user = context.getBean(User.class);
        System.out.println(user);
    }

    @Test
    public void testBeanByAnnotation2() {
        UserController bean = context.getBean(UserController.class);
        bean.listUsers();
    }
}
